/*********************************************************************
	\file :           os_sw_layers\bios\services\scheduler\Os_Types.h
	\brief:           Provide the required data definitions for Task Management services support.
	\author:          Manuel Sandoval
	\version:         1.0
	\date:            Sat, 01, March 2014
*********************************************************************/

#ifndef Os_Types_H
#define Os_Types_H

/******************************* Includes**********************************/

#include "typedef_OS.h"
#include "Mcu.h"


/******************************* Typedef ******************************/

typedef u16 TaskType;							/*!< Identifies a task, commonly associated with the TaskID. */
typedef u8 TaskStateType;						/*!< Reference to a variable of type TaskType. */

typedef TaskType* TaskRefType;					/*!< Identifies a task state. */
typedef TaskStateType* TaskStateRefType;		/*!< Reference to a variable of type TaskStateType */


/******************************* Defines **********************************/

#ifndef TASK
#define TASK(taskID) void taskID(void)
#endif

#define ISR(isr_name)    void interrupt Os_Entry_##isr_name( void )

#define DeclareTask(taskID) extern TASK(taskID)
#define DeclareISR(isr)     extern ISR(isr)




/******************************* Enumerations******************************/
typedef enum Os_StatusType
{
  E_OK = 0,
  E_OS_ACCESS,
  E_OS_CALLEVEL,
  E_OS_ID,
  E_OS_LIMIT,
  E_OS_NOFUNC,
  E_OS_RESOURCE,
  E_OS_STATE,
  E_OS_VALUE,
}Os_StatusType;


/* Task Scheduler Tasks IDs definitions */
typedef enum Os_TaskIDType
{

    TASKS_1_MS = 0,
    TASKS_4_MS,
    TASKS_8_MS,
    TASKS_16_MS,
    TASKS_32_MS,
    TASKS_64_MS,
	  TASK_PITCh1,
  	TASK_PITCh2,
  	TASK_PP0,
  	TASK_PP1,
    NONE,
    TASK_MAX_NUM = NONE,
  	INVALID_TASK
}Os_TaskIDType;


/* Task Scheduler Tasks State definitions */
typedef enum Os_TaskStateType
{
    SUSPENDED = 0,
    READY,
    RUNNING,
}Os_TaskStateType;


/* Task Scheduler Tasks Activation definitions */
typedef enum TaskActivationType
{
  TASK_Periodic = 0,
  TASK_Event
}TaskActivationType;

/******************************* Structures *******************************/
/* Data structure to save task context */
typedef struct Os_TaskStack
{
  u16 l_CCR;
  u8  l_B;
  u8  l_A;
  u16 l_X;
  u16 l_Y;
  u16 l_PC;
  u8  l_PPage;
  void(*Callback)(void);
  boolean bolstackstored;
} Os_TaskStack;

/******************************* Global Variables **********************************/

/******************************* Functions ********************************/


/** @} *//* End of Scheduler Types Group */

#endif /* Os_Types_H */

/*********************************************************************
	File	: os_sw_layers\bios\mcu\Mcu_Cfg.h 
*********************************************************************/
